import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

/*
 * 系统控制和设备群控制
 */
class DeviceCollection extends StatefulWidget {
  String? sysId, modelId;

  DeviceCollection({Key? key, this.sysId, this.modelId}) : super(key: key);

  @override
  State<DeviceCollection> createState() => _DeviceCollectionState();
}

class _DeviceCollectionState extends State<DeviceCollection>
    with AutomaticKeepAliveClientMixin {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return SafeArea(
      child: Container(
        child: InAppWebView(
          initialUrlRequest: URLRequest(
              url: widget.modelId == null
                  ? Uri.parse(
                      "http://dev.intellnect.com/#/app/remoteControl?sysId=179&token=7ab03792-a73a-4321-988c-9aee14111bf7")
                  : Uri.parse(
                      "http://dev.intellnect.com/#/app/remoteBatchControl?modelId=37&sysId=179&token=7ab03792-a73a-4321-988c-9aee14111bf7")),
          initialOptions: InAppWebViewGroupOptions(
            crossPlatform: InAppWebViewOptions(
                useShouldOverrideUrlLoading: true,
                mediaPlaybackRequiresUserGesture: false,
                javaScriptEnabled: true),
            android: AndroidInAppWebViewOptions(
              useHybridComposition: true,
            ),
            ios: IOSInAppWebViewOptions(
              allowsInlineMediaPlayback: true,
            ),
          ),
        ),
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
